package com.yanqu.road.entity.kowloon.common;

/**
 * 矩形类
 */
public class Rect {

    private double x;

    private double y;

    private double width;

    private double height;

    public Rect(double x, double y, double width, double height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    public double getMaxY() {
        return y + height;
    }

    public double getMaxX() {
        return x + width;
    }

    public boolean contains(Vec2 point) {
        return (this.x <= point.getX() &&
                this.x + this.width >= point.getX() &&
                this.y <= point.getY() &&
                this.y + this.height >= point.getY());
    };
}
